package com.summarecon.qualitycontrol;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

import com.summarecon.database.*;

public class DefectTypeActivity extends Activity {
	GridView gridView;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
 		setContentView(R.layout.activity_defect_type);
 		
 		gridView = (GridView) findViewById(R.id.listDefectType);
		
		DatabaseDefectType dbDefectType = new DatabaseDefectType(DefectTypeActivity.this);
		dbDefectType.open();
		String[] data = dbDefectType.getAllRowsAsArrays();
		dbDefectType.close();
		Log.i("data", data.toString());
		
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,data);
		gridView.setAdapter(adapter);
 
		gridView.setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView<?> parent, View v,
				int position, long id) {
				Intent myIntent = new Intent(getBaseContext(), FloorActivity.class);
				startActivity(myIntent);
				finish();
			}
		});

	}
}
